package com.cskaoyan.app.wxservice.impl;

import com.cskaoyan.app.bean.common.BasePageInfo;
import com.cskaoyan.app.bean.common.CommonData;
import com.cskaoyan.app.bean.po.MarketBrand;
import com.cskaoyan.app.bean.po.MarketBrandExample;
import com.cskaoyan.app.mapper.MarketBrandMapper;
import com.cskaoyan.app.wxservice.WxBrandService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WxBrandServiceImpl implements WxBrandService {

    @Autowired
    private MarketBrandMapper brandMapper;

    @Override
    public CommonData<MarketBrand> list(BasePageInfo info) {
        MarketBrandExample example = new MarketBrandExample();
        example.or().andDeletedEqualTo(false);

        PageHelper.startPage(info.getPage(), info.getLimit());
        List<MarketBrand> brandList = brandMapper.selectByExample(example);
        PageInfo<MarketBrand> pageInfo = new PageInfo<>(brandList);

        return CommonData.data(pageInfo);
    }

    @Override
    public MarketBrand detail(Integer id) {
        return brandMapper.selectByPrimaryKey(id);
    }
}
